package cool.tianyou.blue.bird.service;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;

public class MQTTServiceConnection implements ServiceConnection {
    private boolean connected = false;
    private MQTTService mqttService;

    public boolean isConnected() {
        return connected;
    }

    private MQTTMessageCallBack MQTTMessageCallBack;

    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        mqttService = ((MQTTService.CustomBinder) iBinder).getService();
        mqttService.addIGetMessageCallBack(MQTTMessageCallBack);
        connected = true;
    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        connected = false;
    }

    public MQTTService getMqttService() {
        return mqttService;
    }

    public void setIGetMessageCallBack(MQTTMessageCallBack MQTTMessageCallBack) {
        this.MQTTMessageCallBack = MQTTMessageCallBack;
    }
}
